﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%
if sid="Null" then 
Response.Redirect "/login.asp?sid="&sidd&"&url=/user/myface.asp"
end if
	IF Request.QueryString("Action")="save" Then
		call save
	else
		call add
	End IF
end Function

sub add
dim rs,sql
dim urls,sid2
urls=Request.QueryString("url")
if urls="" then urls="index.asp"
	dim Runtxt
	Runtxt=qingtian.RunStr
select case v
case "0"
%>
<card title="帐户冲值"><p align="<%=qingtian.px%>">
	请您务必选择正确的充值卡金额,否则出错后果自负<br/>
	选择充值金额:<br/>
	<select name='Money' value='50'>
	<option value='10'>神州行10元冲值卡</option>
	<option value='30'>神州行30元冲值卡</option>
	<option value='50'>神州行50元冲值卡</option>
	<option value='100'>神州行100元冲值卡</option>
	<option value='300'>神州行300元冲值卡</option>
	</select><br/>
	神州行充值卡序列号:<br/>
	<input name="name<%=Runtxt%>" type="text" format="*N" emptyok="true" maxlength="17" value=""/><br/>
	神州行充值卡密码:<br/><input name="pass<%=Runtxt%>" type="text" format="*N" emptyok="true" maxlength="18" value=""/><br/>
	<anchor title="确定">立即冲值
	<go href="myface.asp?Action=save&amp;sid=<%=sidd%>&amp;urls=<%=urls%>" method="post" accept-charset="utf-8">
	<postfield name="name" value="$(name<%=Runtxt%>)"/>
	<postfield name="pass" value="$(pass<%=Runtxt%>)"/>
	<postfield name="Money" value="$(Money)"/></go></anchor> 
	<br/>--------------<br/>
<%
case "1"
%>
<title>帐户冲值</title>
</head>
<body>
	<div class="footer">请您务必选择正确的充值卡金额,否则出错后果自负</div>
	<div class="block4">选择充值金额:<br/>
        <form action="myface.asp?Action=save&amp;sid=<%=sidd%>&amp;urls=<%=urls%>" method="post">
	<select name='Money' value='50'>
	<option value='10'>神州行10元冲值卡</option>
	<option value='30'>神州行30元冲值卡</option>
	<option value='50'>神州行50元冲值卡</option>
	<option value='100'>神州行100元冲值卡</option>
	<option value='300'>神州行300元冲值卡</option>
	</select></div>
	<div class="footer">神州行充值卡序列号:</div>
	<input name="name" type="text" format="*N" emptyok="true" maxlength="17" value=""/><br/>
	<div class="block4">神州行充值卡密码:</div><input name="pass" type="text" format="*N" emptyok="true" maxlength="18" value=""/><br/>
	<input type="submit" value="立即冲值"/>
<%

End Select

end sub
sub save
	dim rs,sql


	dim name,pass,Money,errmsg,flag,myid

		name=Replace(Request.form("name"),"'","''")
		pass=Replace(Request.form("pass"),"'","''")
		Money=Replace(Request.form("Money"),"'","''")
                myid=qingtian.nid
		if name=""  then errmsg=errmsg&"充值卡序列号不能为空<br/>":flag=0
		if pass=""  then errmsg=errmsg&"充值卡密码不能为空<br/>":flag=0
		if Money=""  then errmsg=errmsg&"请选择充值金额<br/>":flag=0
		if len(name)<>17  then errmsg=errmsg&"充值卡序列号不正确<br/>":flag=0
		if len(pass)<>18  then errmsg=errmsg&"充值卡密码不正确<br/>":flag=0
		if Not IsNumeric(name)  then errmsg=errmsg&"充值卡序列号不正确<br/>":flag=0
		if Not IsNumeric(pass)  then errmsg=errmsg&"充值卡密码不正确<br/>":flag=0


	IF  flag<>"0" Then

		dim i
		dim MerId	'商户ID
		dim keyValue	'商户密钥
		dim Orderid	'商户订单号
		dim FrpId	'支付通道类型
		dim BackUrls	'商户接收支付成功数据的地址
		Dim returnMsg	'提交返回信息
		FrpId="SZX"
		BackUrls="http://"&Request.ServerVariables("SERVER_NAME")&"/user/zfpaycallBack.asp"


		Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "SELECT top 1 [zfpay],[keyValue] FROM [qingtian_config]"
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof) then
		MerId=rs("zfpay")
		keyValue=rs("keyValue")
		end if
		Rs.close
		set rs=nothing


		randomize

		Orderid=year(now()) & month(now()) & day(now()) & weekday(now()) & hour(now()) & minute(now()) & second(now()) & MerId & int((9)*rnd+1)

		for i=1 to 5
		randomize
		Orderid=Orderid&int((9)*rnd+1)
		Next


		set rs=Server.CreateObject("Adodb.Recordset")
  		sql="select * FROM [qingtian_jilu] where nid="&myid&" and [name]='" &name&"' and pass='"&pass&"'"
  		rs.open sql,conn,1,1
		if not (rs.bof and rs.eof)  then
                errmsg="冲值出错,已存在该充值卡,请重新输入!<br/><a href=""myface.asp?sid="&sidd&"&amp;urls="&Request.QueryString("url")&""">返回冲值</a>"
		else

				rs.close

 				sql="select * FROM [qingtian_jilu]"
  				rs.open sql,conn,1,3
				rs.addnew
				rs("nid")=myid
				rs("name")=name
				rs("pass")=pass
				rs("Money")=Money
				rs("Order")=Orderid
				rs("ext")=3007
				rs.update




				' 支付正式请求
				returnMsg = ResultCard(MerId,keyValue,Orderid,Money,name,pass,FrpId,BackUrls)


                                errmsg = returnMsg&"<a href=""myface.asp?sid="&sidd&"&amp;urls="&Request.QueryString("url")&""">返回冲值</a>"	

		end if
		Rs.close
		set rs=nothing



	else
                errmsg=errmsg&"<a href=""myface.asp?sid="&sidd&"&amp;urls="&Request.QueryString("url")&""">返回冲值</a>"
	end if
select case v
case "0"
%>
<card title="帐户冲值"><p align="<%=qingtian.px%>">
<%=errmsg%>
<%
case "1"
%>
<title>帐户冲值</title>
</head>
<body>
<div class="footer">
<%=errmsg%>
</div>
<%
End Select
end sub
%>
